package v1

import (
	"gitee.com/liangziyisheng/caas-platform-mc/internal/consts"
	"gitee.com/liangziyisheng/caas-platform-mc/internal/model/do"

	"gitee.com/liangziyisheng/caas-platform-mc/internal/model/entity"

	"github.com/gogf/gf/v2/frame/g"
)

type ListReq struct {
	g.Meta `path:"/apps" tags:"应用管理" method:"get" summary:"应用列表"`
	Name   string `json:"name"        description:"应用名称"`
	Type   string `json:"type"  description:"应用类型 web,weixin,app"`
}
type ListRes struct {
	g.Meta `mime:"application/json"`
	Data   []AppRes `json:"data" description:"应用列表"`
}

type TypesReq struct {
	g.Meta `path:"/apps/types" tags:"应用管理" method:"get" summary:"应用类型列表"`
}
type TypesRes struct {
	g.Meta `mime:"application/json"`
	Data   []consts.DdicType2 `json:"data" description:"应用列表"`
}

type AddReq struct {
	g.Meta      `path:"/apps" tags:"应用管理" method:"post" summary:"添加应用"`
	Code        string `json:"code" v:"required#编码不能为空" description:"应用编码"`
	Name        string `json:"name" v:"required#Name不能为空" description:"应用名称"`
	Type        string `json:"type" v:"required#Type不能为空" description:"应用类型 web,weixin,app"`
	Description string `json:"description" description:"应用描述"`
}
type AddRes struct {
	g.Meta `mime:"application/json"`
	Id     int64 `json:"id" description:"新增应用id"`
}

type UpdateReq struct {
	g.Meta      `path:"/apps/{id}" tags:"应用管理" method:"put" summary:"更新应用"`
	Id          int64  `query:"id" json:"id" v:"required|min:1"`
	Name        string `json:"name" description:"应用名称"`
	Type        string `json:"type" description:"应用类型"`
	Description string `json:"description" description:"应用描述"`
}
type UpdateRes struct {
	g.Meta `mime:"application/json"`
	Rows   int64 `json:"rows" description:"修改成功的行数"`
}

type DeleteReq struct {
	g.Meta `path:"/apps/{id}" tags:"应用管理" method:"delete" summary:"删除应用"`
	Id     int64 `query:"id" v:"required|min:1"`
}
type DeleteRes struct {
	g.Meta `mime:"application/json"`
	Rows   int64 `json:"rows" description:"删除成功的行数"`
}
type InfoReq struct {
	g.Meta `path:"/apps/{id}" tags:"应用管理" method:"get" summary:"应用详情"`
	Id     int64 `query:"id" v:"required|min:1"`
}

type InfoRes struct {
	g.Meta      `mime:"application/json"`
	Id          int64       `json:"id" description:""`
	Name        string      `json:"name" description:"应用名称"`
	Type        string      `json:"type" description:"应用类型"`
	Description string      `json:"description" description:"应用描述"`
	Components  []Component `json:"components" description:"应用组件"`
	Menus       []Menu      `json:"permissions" description:"应用权限"`
}

type AppRes struct {
	Id          int64  `json:"id" description:""`
	Name        string `json:"name" description:"应用名称"`
	Code        string `json:"code" description:"应用编码"`
	Type        string `json:"type" description:"应用类型"`
	Description string `json:"description" description:"应用描述"`
}
type Component struct {
	Id          int64  `json:"id" description:""`
	Name        string `json:"name" description:"组件名称"`
	Description string `json:"description" description:"组件描述"`
}
type Menu struct {
	Id          int64  `json:"id"`
	Name        string `json:"name"`
	Type        int    `json:"type"`
	Description string `json:"description"`
}

// input and output structs
type ListInput struct {
	Name string `json:"name"        description:"应用名称"`
	Type string `json:"type"  description:"应用类型 web,weixin,app"`
}
type ListOutput struct {
	Data []entity.App `json:"data" description:"应用列表"`
}

type AddInput struct {
	do.App
}
type AddOutput struct {
	Id int64 `json:"id" description:"新增应用id"`
}

type UpdateInput struct {
	do.App
}

type UpdateOutput struct {
	Rows int64 `json:"rows" description:"修改成功的行数"`
}

type DeleteInput struct {
	Id int64 `json:"id" v:"required#ID不能为空"`
}
type DeleteOutput struct {
	Rows int64 `json:"rows" description:"删除成功的行数"`
}

type InfoInput struct {
	Id int64 `json:"id" v:"required#ID不能为空"`
}

type InfoOutput struct {
	Id          int64                 `json:"id" description:""`
	Name        string                `json:"name" description:"应用名称"`
	Type        string                `json:"type" description:"应用类型"`
	Description string                `json:"description" description:"应用描述"`
	Components  []entity.AppComponent `json:"components" description:"应用组件"`
	Menus       []entity.AppMenu      `json:"permissions" description:"应用权限"`
}
